package com.swh.service.Impl;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.swh.dao.WorkOrderDao;
import com.swh.entity.QualificationCondition;
import com.swh.entity.WorkOrder;
import com.swh.service.WorkOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;
import java.util.List;

/**
 * @Author: swh
 * @Description:
 * @Date: 2020/12/14 14:46
 * @Version: 1.0
 */
@Service
public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrder> implements WorkOrderService {

    @Autowired
    public WorkOrderServiceImpl(WorkOrderDao workOrderDao) {
        super(workOrderDao);
    }

    @Autowired
    private WorkOrderDao workOrderDao;



    @Override
    public PageInfo<Map> selectPage(Integer pageNum, Integer pageSize, QualificationCondition condition) {
        PageHelper.startPage(pageNum,pageSize);
        List<Map> list = workOrderDao.selectPage((pageNum -1) * pageSize, pageSize, condition);
        return new PageInfo<>(list);
    }



    @Override
    public Map<String, Object> findByOrder(Integer orderId) {
        //需要查两次sql

        //第一个sql：根据工单ID 查询三方公司的详情（后续打印信息需要用到）
        Map<String, Object> info = workOrderDao.findCompanyByOrder(orderId);
        //第二个sql：根据工单ID 查询废物详情（列表数据）
        List<HashMap> wastes = workOrderDao.findWasteDetailByOrder(orderId);
        info.put("wastes",wastes);
        return info;
    }



}
